/**
 * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.crossriver.crgis.database.service.http;

import com.crossriver.crgis.database.model.Transactions;

import com.liferay.portal.kernel.json.JSONArray;
import com.liferay.portal.kernel.json.JSONFactoryUtil;
import com.liferay.portal.kernel.json.JSONObject;
import com.liferay.portal.kernel.util.StringPool;

import java.util.Date;
import java.util.List;

/**
 * @author    Wole Adetiba
 * @generated
 */
public class TransactionsJSONSerializer {
	public static JSONObject toJSONObject(Transactions model) {
		JSONObject jsonObj = JSONFactoryUtil.createJSONObject();

		jsonObj.put("transactionNo", model.getTransactionNo());
		jsonObj.put("userId", model.getUserId());
		jsonObj.put("transactionRef", model.getTransactionRef());
		jsonObj.put("itemId", model.getItemId());
		jsonObj.put("itemDescription", model.getItemDescription());
		jsonObj.put("paymentType", model.getPaymentType());

		Date paymentDate = model.getPaymentDate();

		String paymentDateJSON = StringPool.BLANK;

		if (paymentDate != null) {
			paymentDateJSON = String.valueOf(paymentDate.getTime());
		}

		jsonObj.put("paymentDate", paymentDateJSON);
		jsonObj.put("receiptNo", model.getReceiptNo());
		jsonObj.put("invoiceNo", model.getInvoiceNo());
		jsonObj.put("applicationType", model.getApplicationType());
		jsonObj.put("bankCode", model.getBankCode());
		jsonObj.put("bankName", model.getBankName());
		jsonObj.put("bankReference", model.getBankReference());
		jsonObj.put("accountNo", model.getAccountNo());
		jsonObj.put("amount", model.getAmount());
		jsonObj.put("approvedAmount", model.getApprovedAmount());
		jsonObj.put("transactionFee", model.getTransactionFee());
		jsonObj.put("batchId", model.getBatchId());
		jsonObj.put("status", model.getStatus());
		jsonObj.put("responseCode", model.getResponseCode());
		jsonObj.put("responseDescription", model.getResponseDescription());
		jsonObj.put("payRef", model.getPayRef());
		jsonObj.put("retRef", model.getRetRef());
		jsonObj.put("cardNum", model.getCardNum());

		return jsonObj;
	}

	public static JSONArray toJSONArray(
		com.crossriver.crgis.database.model.Transactions[] models) {
		JSONArray jsonArray = JSONFactoryUtil.createJSONArray();

		for (Transactions model : models) {
			jsonArray.put(toJSONObject(model));
		}

		return jsonArray;
	}

	public static JSONArray toJSONArray(
		com.crossriver.crgis.database.model.Transactions[][] models) {
		JSONArray jsonArray = JSONFactoryUtil.createJSONArray();

		for (Transactions[] model : models) {
			jsonArray.put(toJSONArray(model));
		}

		return jsonArray;
	}

	public static JSONArray toJSONArray(
		List<com.crossriver.crgis.database.model.Transactions> models) {
		JSONArray jsonArray = JSONFactoryUtil.createJSONArray();

		for (Transactions model : models) {
			jsonArray.put(toJSONObject(model));
		}

		return jsonArray;
	}
}